Change in openvpn[master]: Multisocket: use event engine rwflags for UDP I/O
A message that is not in the archive (sent off-list or not yet received): gerrit.1776783100000.I6b303805a3688b6f6363140c76853a58badecd8f@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email
to review the following change.
Change subject: Multisocket: use event engine rwflags for UDP I/O
......................................................................
Multisocket: use event engine rwflags for UDP I/O
udp_flags does not guarantee correct association with the socket being processed. Use the rwflags returned by the event engine together with the event to ensure proper per-socket I/O handling.
Remove udp_flags entirely.
This change is based on an investigation triggered by a report from Joshua Rogers using ZeroPath.
---
M src/openvpn/forward.c
M src/openvpn/mudp.c
M src/openvpn/mudp.h
M src/openvpn/multi_io.c
M src/openvpn/multi_io.h
5 files changed, 4 insertions(+), 8 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1635/1
src/openvpn/forward.c +0 -1
@@ -2153,7 +2153,6 @@unsigned int out_socket;multi_io_process_flags (c, multi_io->es, flags, &out_socket,NULL ); - multi_io->udp_flags = (out_socket <<SOCKET_SHIFT ); }/*
src/openvpn/mudp.c +2 -4
@@ -336,9 +336,9 @@* Process a UDP socket event. */ void -multi_process_io_udp (struct multi_context *m,struct link_socket *sock) +multi_process_io_udp (struct multi_context *m,struct link_socket *sock,unsigned int rwflags) { -const unsigned int status = m->multi_io->udp_flags; +const unsigned int status = rwflags;const unsigned int mpp_flags = (MPP_PRE_SELECT |MPP_CLOSE_ON_SIGNAL );/* UDP port ready to accept write */
@@ -355,8 +355,6 @@multi_process_incoming_link (m,NULL , mpp_flags, sock); } } - - m->multi_io->udp_flags =ES_ERROR ; }/*
src/openvpn/mudp.h +1 -1
@@ -32,7 +32,7 @@unsigned int p2mp_iow_flags (const struct multi_context *m); -void multi_process_io_udp (struct multi_context *m,struct link_socket *sock); +void multi_process_io_udp (struct multi_context *m,struct link_socket *sock,unsigned int rwflags);/**************************************************************************/ /** * Get, and if necessary create, the multi_instance associated with a
src/openvpn/multi_io.c +1 -1
@@ -457,7 +457,7 @@ }else { -multi_process_io_udp (m, ev_arg->u.sock); +multi_process_io_udp (m, ev_arg->u.sock, e->rwflags); mi = m->pending; }/* monitor and/or handle events that are
src/openvpn/multi_io.h +0 -1
@@ -55,7 +55,6 @@int n_esr;int maxevents;unsigned int tun_rwflags; -unsigned int udp_flags;#ifdef ENABLE_MANAGEMENT unsigned int management_persist_flags;#endif
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6b303805a3688b6f6363140c76853a58badecd8f
Gerrit-Change-Number: 1635
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: its_Giaan, plaisthos.
ordex has posted comments on this change by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email )
Change subject: Multisocket: use event engine rwflags for UDP I/O
......................................................................
Patch Set 1: Code-Review-1
(1 comment)
File src/openvpn/mudp.c:
http://gerrit.openvpn.net/c/openvpn/+/1635/comment/4b1334a4_3f3cffbb?usp=email :
PS1, Line 341: const unsigned int status = rwflags;
I think we can remove status and directly use rwflags throughout the function body?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6b303805a3688b6f6363140c76853a58badecd8f
Gerrit-Change-Number: 1635
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Comment-Date: Tue, 21 Apr 2026 14:57:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: its_Giaan, ordex, plaisthos.
Hello ordex, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review-1 by ordex
Change subject: Multisocket: use event engine rwflags for UDP I/O
......................................................................
Multisocket: use event engine rwflags for UDP I/O
udp_flags does not guarantee correct association with the socket being processed. Use the rwflags returned by the event engine together with the event to ensure proper per-socket I/O handling.
Remove udp_flags entirely.
This change is based on an investigation triggered by a report from Joshua Rogers using ZeroPath.
---
M src/openvpn/forward.c
M src/openvpn/mudp.c
M src/openvpn/mudp.h
M src/openvpn/multi_io.c
M src/openvpn/multi_io.h
5 files changed, 5 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1635/2
src/openvpn/forward.c +0 -1
@@ -2153,7 +2153,6 @@unsigned int out_socket;multi_io_process_flags (c, multi_io->es, flags, &out_socket,NULL ); - multi_io->udp_flags = (out_socket <<SOCKET_SHIFT ); }/*
src/openvpn/mudp.c +3 -6
@@ -336,18 +336,17 @@* Process a UDP socket event. */ void -multi_process_io_udp (struct multi_context *m,struct link_socket *sock) +multi_process_io_udp (struct multi_context *m,struct link_socket *sock,unsigned int rwflags) { -const unsigned int status = m->multi_io->udp_flags;const unsigned int mpp_flags = (MPP_PRE_SELECT |MPP_CLOSE_ON_SIGNAL );/* UDP port ready to accept write */ -if (status &SOCKET_WRITE ) +if (rwflags &SOCKET_WRITE ) {multi_process_outgoing_link (m, mpp_flags); }/* Incoming data on UDP port */ -else if (status &SOCKET_READ ) +else if (rwflags &SOCKET_READ ) {read_incoming_link (&m->top, sock);if (!IS_SIG (&m->top))
@@ -355,8 +354,6 @@multi_process_incoming_link (m,NULL , mpp_flags, sock); } } - - m->multi_io->udp_flags =ES_ERROR ; }/*
src/openvpn/mudp.h +1 -1
@@ -32,7 +32,7 @@unsigned int p2mp_iow_flags (const struct multi_context *m); -void multi_process_io_udp (struct multi_context *m,struct link_socket *sock); +void multi_process_io_udp (struct multi_context *m,struct link_socket *sock,unsigned int rwflags);/**************************************************************************/ /** * Get, and if necessary create, the multi_instance associated with a
src/openvpn/multi_io.c +1 -1
@@ -457,7 +457,7 @@ }else { -multi_process_io_udp (m, ev_arg->u.sock); +multi_process_io_udp (m, ev_arg->u.sock, e->rwflags); mi = m->pending; }/* monitor and/or handle events that are
src/openvpn/multi_io.h +0 -1
@@ -55,7 +55,6 @@int n_esr;int maxevents;unsigned int tun_rwflags; -unsigned int udp_flags;#ifdef ENABLE_MANAGEMENT unsigned int management_persist_flags;#endif
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6b303805a3688b6f6363140c76853a58badecd8f
Gerrit-Change-Number: 1635
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Attention is currently required from: ordex, plaisthos.
its_Giaan has posted comments on this change by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email )
Change subject: Multisocket: use event engine rwflags for UDP I/O
......................................................................
Patch Set 2:
(1 comment)
File src/openvpn/mudp.c:
http://gerrit.openvpn.net/c/openvpn/+/1635/comment/b423be31_f2681555?usp=email :
PS1, Line 341: const unsigned int status = rwflags;
Quoted 1 line
I think we can remove
statusand directly userwflagsthroughout the function body?
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6b303805a3688b6f6363140c76853a58badecd8f
Gerrit-Change-Number: 1635
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Tue, 21 Apr 2026 15:20:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: ordex <[email protected]...>
Attention is currently required from: ordex, plaisthos.
Hello ordex, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email
to look at the new patch set (#3).
Change subject: Multisocket: use event engine rwflags for UDP I/O
......................................................................
Multisocket: use event engine rwflags for UDP I/O
udp_flags does not guarantee correct association with the socket being processed. Use the rwflags delivered by the event engine along with the event to ensure proper per-socket I/O handling.
Remove udp_flags entirely.
This change is based on an investigation triggered by a report from Joshua Rogers using ZeroPath.
---
M src/openvpn/forward.c
M src/openvpn/mudp.c
M src/openvpn/mudp.h
M src/openvpn/multi_io.c
M src/openvpn/multi_io.h
5 files changed, 8 insertions(+), 28 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1635/3
src/openvpn/forward.c +3 -19
@@ -2029,8 +2029,7 @@ }static void -multi_io_process_flags (struct context *c,struct event_set *es,const unsigned int flags, -unsigned int *out_socket,unsigned int *out_tuntap) +multi_io_process_flags (struct context *c,struct event_set *es,const unsigned int flags) {unsigned int socket =0 ;unsigned int tuntap =0 ;
@@ -2130,16 +2129,6 @@ }tun_set (c->c1.tuntap, es, tuntap, (void *)tun_shift,NULL ); - -if (out_socket) - { - *out_socket = socket; - } - -if (out_tuntap) - { - *out_tuntap = tuntap; - } }/*
@@ -2150,10 +2139,7 @@void get_io_flags_udp (struct context *c,struct multi_io *multi_io,const unsigned int flags) { -unsigned int out_socket; - -multi_io_process_flags (c, multi_io->es, flags, &out_socket,NULL ); - multi_io->udp_flags = (out_socket <<SOCKET_SHIFT ); +multi_io_process_flags (c, multi_io->es, flags); }/*
@@ -2163,8 +2149,6 @@void io_wait (struct context *c,const unsigned int flags) { -unsigned int out_socket; -unsigned int out_tuntap;struct event_set_return esr[4 ];/* These shifts all depend on EVENT_READ and EVENT_WRITE */
@@ -2183,7 +2167,7 @@*/ event_reset (c->c2.event_set); -multi_io_process_flags (c, c->c2.event_set, flags, &out_socket, &out_tuntap); +multi_io_process_flags (c, c->c2.event_set, flags);#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD )if (c->c1.tuntap)
src/openvpn/mudp.c +3 -6
@@ -336,18 +336,17 @@* Process a UDP socket event. */ void -multi_process_io_udp (struct multi_context *m,struct link_socket *sock) +multi_process_io_udp (struct multi_context *m,struct link_socket *sock,unsigned int rwflags) { -const unsigned int status = m->multi_io->udp_flags;const unsigned int mpp_flags = (MPP_PRE_SELECT |MPP_CLOSE_ON_SIGNAL );/* UDP port ready to accept write */ -if (status &SOCKET_WRITE ) +if (rwflags &SOCKET_WRITE ) {multi_process_outgoing_link (m, mpp_flags); }/* Incoming data on UDP port */ -else if (status &SOCKET_READ ) +else if (rwflags &SOCKET_READ ) {read_incoming_link (&m->top, sock);if (!IS_SIG (&m->top))
@@ -355,8 +354,6 @@multi_process_incoming_link (m,NULL , mpp_flags, sock); } } - - m->multi_io->udp_flags =ES_ERROR ; }/*
src/openvpn/mudp.h +1 -1
@@ -32,7 +32,7 @@unsigned int p2mp_iow_flags (const struct multi_context *m); -void multi_process_io_udp (struct multi_context *m,struct link_socket *sock); +void multi_process_io_udp (struct multi_context *m,struct link_socket *sock,unsigned int rwflags);/**************************************************************************/ /** * Get, and if necessary create, the multi_instance associated with a
src/openvpn/multi_io.c +1 -1
@@ -457,7 +457,7 @@ }else { -multi_process_io_udp (m, ev_arg->u.sock); +multi_process_io_udp (m, ev_arg->u.sock, e->rwflags); mi = m->pending; }/* monitor and/or handle events that are
src/openvpn/multi_io.h +0 -1
@@ -55,7 +55,6 @@int n_esr;int maxevents;unsigned int tun_rwflags; -unsigned int udp_flags;#ifdef ENABLE_MANAGEMENT unsigned int management_persist_flags;#endif
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6b303805a3688b6f6363140c76853a58badecd8f
Gerrit-Change-Number: 1635
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Attention is currently required from: its_Giaan, ordex, plaisthos.
cron2 has posted comments on this change by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email )
Change subject: Multisocket: use event engine rwflags for UDP I/O
......................................................................
Patch Set 3: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6b303805a3688b6f6363140c76853a58badecd8f
Gerrit-Change-Number: 1635
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 22 Apr 2026 10:00:39 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH v3 1/1 Multisocket: use event engine rwflags for UDP I/O
In reply to a message not in the archiveFrom: Gianmarco De Gregori <[email protected]...>
udp_flags does not guarantee correct association with the socket being processed. Use the rwflags delivered by the event engine along with the event to ensure proper per-socket I/O handling.
Remove udp_flags entirely.
This change is based on an investigation triggered by a report from Joshua Rogers using ZeroPath.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1635
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1635
This mail reflects revision 3 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/forward.c +3 -19
@@ -2029,8 +2029,7 @@ }static void -multi_io_process_flags (struct context *c,struct event_set *es,const unsigned int flags, -unsigned int *out_socket,unsigned int *out_tuntap) +multi_io_process_flags (struct context *c,struct event_set *es,const unsigned int flags) {unsigned int socket =0 ;unsigned int tuntap =0 ;
@@ -2130,16 +2129,6 @@ }tun_set (c->c1.tuntap, es, tuntap, (void *)tun_shift,NULL ); - -if (out_socket) - { - *out_socket = socket; - } - -if (out_tuntap) - { - *out_tuntap = tuntap; - } }/*
@@ -2150,10 +2139,7 @@void get_io_flags_udp (struct context *c,struct multi_io *multi_io,const unsigned int flags) { -unsigned int out_socket; - -multi_io_process_flags (c, multi_io->es, flags, &out_socket,NULL ); - multi_io->udp_flags = (out_socket <<SOCKET_SHIFT ); +multi_io_process_flags (c, multi_io->es, flags); }/*
@@ -2163,8 +2149,6 @@void io_wait (struct context *c,const unsigned int flags) { -unsigned int out_socket; -unsigned int out_tuntap;struct event_set_return esr[4 ];/* These shifts all depend on EVENT_READ and EVENT_WRITE */
@@ -2183,7 +2167,7 @@*/ event_reset (c->c2.event_set); -multi_io_process_flags (c, c->c2.event_set, flags, &out_socket, &out_tuntap); +multi_io_process_flags (c, c->c2.event_set, flags);#if defined(TARGET_LINUX ) || defined(TARGET_FREEBSD )if (c->c1.tuntap)
src/openvpn/mudp.c +3 -6
@@ -336,18 +336,17 @@* Process a UDP socket event. */ void -multi_process_io_udp (struct multi_context *m,struct link_socket *sock) +multi_process_io_udp (struct multi_context *m,struct link_socket *sock,unsigned int rwflags) { -const unsigned int status = m->multi_io->udp_flags;const unsigned int mpp_flags = (MPP_PRE_SELECT |MPP_CLOSE_ON_SIGNAL );/* UDP port ready to accept write */ -if (status &SOCKET_WRITE ) +if (rwflags &SOCKET_WRITE ) {multi_process_outgoing_link (m, mpp_flags); }/* Incoming data on UDP port */ -else if (status &SOCKET_READ ) +else if (rwflags &SOCKET_READ ) {read_incoming_link (&m->top, sock);if (!IS_SIG (&m->top))
@@ -355,8 +354,6 @@multi_process_incoming_link (m,NULL , mpp_flags, sock); } } - - m->multi_io->udp_flags =ES_ERROR ; }/*
src/openvpn/mudp.h +1 -1
@@ -32,7 +32,7 @@unsigned int p2mp_iow_flags (const struct multi_context *m); -void multi_process_io_udp (struct multi_context *m,struct link_socket *sock); +void multi_process_io_udp (struct multi_context *m,struct link_socket *sock,unsigned int rwflags);/**************************************************************************/ /** * Get, and if necessary create, the multi_instance associated with a
src/openvpn/multi_io.c +1 -1
@@ -457,7 +457,7 @@ }else { -multi_process_io_udp (m, ev_arg->u.sock); +multi_process_io_udp (m, ev_arg->u.sock, e->rwflags); mi = m->pending; }/* monitor and/or handle events that are
src/openvpn/multi_io.h +0 -1
@@ -55,7 +55,6 @@int n_esr;int maxevents;unsigned int tun_rwflags; -unsigned int udp_flags;#ifdef ENABLE_MANAGEMENT unsigned int management_persist_flags;#endif
Attention is currently required from: its_Giaan, ordex, plaisthos.
cron2 has posted comments on this change by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email )
The change is no longer submittable: Code-Review is unsatisfied now.
Change subject: Multisocket: use event engine rwflags for UDP I/O
......................................................................
Patch Set 3: -Code-Review
(1 comment)
Patchset:
PS3:
12:04 < Giaan> cron2: wait do not proceed with #1635 12:04 < Giaan> just found more
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1635?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6b303805a3688b6f6363140c76853a58badecd8f
Gerrit-Change-Number: 1635
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 22 Apr 2026 10:14:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes